//
//  UIViewController+MMSpinner.m
//  Auditory
//
//  Created by 寒竹子 on 15/5/3.
//  Copyright (c) 2015年 寒竹子. All rights reserved.
//

#import "UIViewController+MMSpinner.h"
#import "MMMaterialDesignSpinner.h"

@interface UIViewController()
@property (nonatomic, strong) MMMaterialDesignSpinner * spinner;
@end

@implementation UIViewController (MMSpinner)

// 加载动画
- (void)addMMSpinner
{
    MMMaterialDesignSpinner * spinner = [[MMMaterialDesignSpinner alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 40.0f) / 2.0f, (self.view.frame.size.height - 40.0f - 64.0f) / 2.0f, 40, 40)];
    spinner.tag = 10001;
    
    spinner.lineWidth = 2.0f;
    spinner.tintColor = [UIColor redColor];
    [self.view addSubview:spinner];
    [spinner startAnimating];
}

// 移除加载动画
- (void)removeMMSpinner
{
    MMMaterialDesignSpinner * spinner = (MMMaterialDesignSpinner *)[self.view viewWithTag:10001];
    if ([spinner isAnimating]) {
        [spinner stopAnimating];
        [spinner removeFromSuperview];
    }
}

@end
